#include "Menu.h"


int main ( int argc, char** argv )
{
    // initialize SDL video
    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        return 1;
    }

    if(TTF_Init() < 0 )
    {
        printf("Impossible d'initialiser SDL_ttf : %s", TTF_GetError());
        return 1;
    }

    // make sure SDL cleans up before exit
    atexit(SDL_Quit);

    Config_Menu();
    // program main loop
    int done = 0;
    while (!done)
    {
        // message processing loop
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                // exit if the window is closed
            case SDL_QUIT:
                done = 1;
                break;

                // check for keypresses
            case SDL_KEYDOWN:
                {
                    // exit if ESCAPE is pressed
                    if (event.key.keysym.sym == SDLK_ESCAPE)
                        done = 1;
                    break;
                }
                /* case SDL_MOUSEBUTTONUP:
              if (   event.button.y > 200
                  && event.button.y <= 200+HAUTEUR   // si clic sur boutton
                  && event.button.x > 150
                  && event.button.x <= 150+LARGEUR )*/ //Coordonnée de clikage :)
              /*.......*/
            break;
            } // end switch
        } // end of message processing

        // DRAWING STARTS HERE

        // clear screen
        SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));


        // draw bitmap
        SDL_BlitSurface(Image_fond, 0, screen, &dstrect);
        SDL_BlitSurface(Bouton1, 0, screen, &rect1);
        SDL_BlitSurface(Bouton2, 0, screen, &rect2);
        SDL_BlitSurface(Bouton3, 0, screen, &rect3);
        SDL_BlitSurface(Bouton4, 0, screen, &rect4);
        /* Affiche toute la surface en 0,0 */
        SDL_BlitSurface(TextSurface, NULL, MainScreen, &Text);

        // DRAWING ENDS HERE

      // finally, update the screen :)
       SDL_Flip(screen);

    } // end main loop

    // free loaded bitmap
    SDL_FreeSurface(Bouton1);
    SDL_FreeSurface(Image_fond);
    SDL_FreeSurface(TextSurface);

    TTF_CloseFont(Font);

    TTF_Quit();

    // all is well ;)
    printf("Exited cleanly\n");
    return 0;
}

